#ifndef __LUAPRINT_H__
#define __LUAPRINT_H__



#ifdef _WIN32
#include <windows.h>
#endif
#include <stdio.h>
#include <stdarg.h>

enum ELuaPrint
{
  ELP_NORMAL,
  ELP_ERROR,
  ELP_MAX,
};

enum ELuaError
{
  ELR_VALUEWRONGTYPE,
  ELR_STACKNOBANLENCE,
  ELR_MAX,
};


class CLuaPrint
{
public:
  static void LuaError(ELuaError err)
  {
    Print(ELP_ERROR,SHOWERROR[err]);
  }
  static void LuaShow(char* msg,...)
  {
    va_list va;
    va_start(va,msg);
    Print(ELP_ERROR,msg,va); 
    va_end(va);
  }

private:
  static void Print(ELuaPrint type,char* msg,va_list va)
  {
	  type=type;
#if defined(_WIN32)&&defined(_DEBUG)&&defined(_CONSOLE)
    if(type!=ELP_NORMAL)
    {
      switch (type)
      {
      case ELP_ERROR:
        SetColor(FOREGROUND_RED,0);
        break;
      }
    }
#endif
    vprintf(msg,va);
    printf("\n");
    
#if defined(_WIN32)&&defined(_DEBUG)&&defined(_CONSOLE)
    if(type!=ELP_NORMAL)
    {
      SetColor(FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_RED,0);
    }
#endif
  }

  static void Print(ELuaPrint type,char* msg)
  {
	  type=type;
#if defined(_WIN32)&&defined(_DEBUG)&&defined(_CONSOLE)
    if(type!=ELP_NORMAL)
    {
      switch (type)
      {
      case ELP_ERROR:
        SetColor(FOREGROUND_RED,0);
        break;
      }
    }
#endif
    printf(msg);
    printf("\n");

#if defined(_WIN32)&&defined(_DEBUG)&&defined(_CONSOLE)
    if(type!=ELP_NORMAL)
    {
      SetColor(FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_RED,0);
    }
#endif
  }

#if defined(_WIN32)&&defined(_DEBUG)&&defined(_CONSOLE)
  static inline void SetColor(unsigned short ForColor, unsigned short BackColor)
  {
    HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);            
    SetConsoleTextAttribute(hCon,ForColor|BackColor);
  }
#endif
private:
  static char* SHOWERROR[ELR_MAX];
};



#endif


